/**
 * Copyright (C) 2008 aileron.cc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cc.aileron.mailet.daemon;

import java.security.Security;
import java.util.Properties;

import javax.mail.URLName;

/**
 * 接続情報
 * @author Aileron
 *
 */
public class MailetDaemonSetting
{
    /**
     * port
     */
    public static final String port = "995";
    
    /**
     * properties 
     */
    public static final Properties properties;
    static
    {
        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
        properties = System.getProperties();
        properties.setProperty("mail.pop3.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        properties.setProperty("mail.pop3.socketFactory.fallback", "false");
        properties.setProperty("mail.pop3.port", port);
        properties.setProperty("mail.pop3.socketFactory.port", port);
    }
    
    /**
     * urlname
     * @return
     */
    public URLName urlName()
    {
        return new URLName("pop3", host, Integer.parseInt(port), null, user, pass);
    }
    
    /**
     * constractor setting
     * @param host
     * @param user
     * @param pass
     */
    public MailetDaemonSetting(
            final String host,
            final String user,
            final String pass)
    {
        this.host = host;
        this.user = user;
        this.pass = pass;
    }
    
    /**
     * 接続先
     */
    public final String host;
    
    /**
     * user
     */
    public final String user;
    
    /**
     * pass
     */
    public final String pass;
}